<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/_mozilla/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
promise_test(() => {
    window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate);
    return window.navigator.bluetooth.requestDevice({
        filters: [{services: [heart_rate.name]}]
    })
    .then(device => {
        return device.gatt.connect()
        .then(gattServer => {
            assert_true(gattServer.connected);
            gattServer.disconnect();
            assert_false(gattServer.connected);
        })
        .then(() => device.gatt.connect()).then(gattServer => {
            assert_true(gattServer.connected);
            gattServer.disconnect();
            assert_false(gattServer.connected);
        });
    });
}, 'Connect + Disconnect twice still results in \'connected\' being false.');
</script>
